#ifndef SOCKET_H_
#define SOCKET_H_

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string>
#include <iostream>
#include <unistd.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <fcntl.h>

using namespace std;

class Socket {
protected:
	int fileDescriptor;
	sockaddr_in address;
    struct timeval tv;
	bool conectado;

public:
	Socket();
	Socket(const unsigned int segundos, const unsigned int usegundos);
	virtual ~Socket();
	bool create();
	bool connect(const string &hostname , unsigned int port);
	bool listen(const unsigned int maxClientes);
	bool bind(const unsigned int port );
	bool shutdown();
	int close();
	bool send(const char *stream, unsigned int size) const;
	bool recv(char *stream, unsigned int size) const;
	Socket* accept();
	bool esValido() const;
	bool getConectado();

protected:
	Socket(int fileDescriptor);
};

#endif /* SOCKET_H_ */
